home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / hello_localized / hello.c < prev    next >
C/C++ Source or Header  |  1995-09-01  |  2KB  |  70 lines

  1. ;/* Source-File: test.c                     Hello_World - LOCALIZED!
  2.  
  3. CatComp hello.cd CFILE hello_strings.h OBJFILE hello_strings.o
  4. CatComp hello.cd hello.ct CATALOG sys:locale/Catalogs/Français/hello.catalog NOOPTIM
  5. Quit
  6. */
  7.  
  8. /* [Definition Includes] ****************************************************/
  9.  
  10. #define CATCOMP_NUMBERS
  11. #include "hello_strings.h"
  12. #include <libraries/locale.h>
  13. #include <clib/exec_protos.h>
  14. #include <clib/locale_protos.h>
  15. #include <pragmas/exec_pragmas.h>
  16. #include <pragmas/locale_pragmas.h>
  17. #include <string.h>
  18. #include <proto/dos.h>
  19. #include <proto/exec.h>
  20.  
  21. /* [Definition of Prototypes] ***********************************************/
  22.  
  23. STRPTR    __asm GetString(register __a0 struct LocaleInfo *li, register __d0 LONG stringNum);
  24.  
  25.  
  26. /* [Main-Program] **********************************************************
  27.  
  28.    This tiny localization example uses >NO< startupcode.. instead it uses 
  29.    the dos Write() function to write the string directly to the console 
  30.    window... so run from the CLI only!
  31.  
  32. */
  33.  
  34. void hello(void)
  35. {
  36. struct Library *LocaleBase;        // locale library base
  37. struct LocaleInfo li;
  38.  
  39. /* Open Dos Library */
  40.  
  41.    struct DosLibrary *DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 0L);
  42.  
  43. /* Open Locale Library */
  44.  
  45.     li.li_Catalog = NULL;
  46.     if(LocaleBase = OpenLibrary("locale.library",38))
  47.         {
  48.         li.li_LocaleBase = LocaleBase;
  49.         li.li_Catalog    = OpenCatalogA(NULL,"hello.catalog",NULL);
  50.         }
  51.  
  52. /* Translate one string.. for our example & write it to CLI window */
  53.  
  54.    Write(Output(), GetString(&li,MSG_HELLO), strlen(GetString(&li,MSG_HELLO)));
  55.  
  56. /* Close Locale Library */
  57.  
  58.     if (LocaleBase)
  59.         {
  60.         CloseCatalog(li.li_Catalog);
  61.         CloseLibrary(LocaleBase);
  62.         }
  63.  
  64. /* Close DOS Library & exit program... */
  65.  
  66.    CloseLibrary((struct Library *)DOSBase);
  67.  
  68. }
  69.  
  70.